package org.micservice.controller;


import org.micservice.ResultMap;
import org.micservice.User;
import org.micservice.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("provider")
public class Provider1Controller {

    @Autowired
    UserService userService;

    @RequestMapping("getUsers")
    public ResultMap<List<User>> getUsers() {
        return userService.getUserList();
    }

    @RequestMapping("addUser")
    public ResultMap addUser(@RequestBody User user) throws Exception {
        int i = userService.addUser(user);
        ResultMap resultMap = new ResultMap();
        if (i > 0) {
            resultMap.setCode(i);
            resultMap.setMsg("添加成功");
        }
        return resultMap;

    }

}
